package framework.movements;

public class LinearStrategy implements MovementStrategy {
	
	public LinearMovement m;
	
	public LinearStrategy(LinearMovement m) {
		this.m = m;
	}

	@Override
	public int computeX(int delta) {
		int stepX = (int) (((m.getEndPoint().getX() - m.getStartPoint().getX())) * delta / (m.getDuration() - m.getStayTimeEnd()));
		return m.getX() + stepX;
	}

	@Override
	public int computeY(int delta) {
		int stepY = (int) (((m.getEndPoint().getY() - m.getStartPoint().getY())) * delta / (m.getDuration() - m.getStayTimeEnd()));
		return m.getY() + stepY;
	}
	
	public float getSlope() {
		return (m.getEndPoint().getX() - m.getStartPoint().getX()) /
			   (m.getEndPoint().getY() - m.getStartPoint().getY());
	}
}
